<?php
class Editors {
        var $id = '';
        var $name = '';
        var $value = '';
        var $textarea = '';
        var $height = '300px';
        var $minWidth = '474px';
        function __construct($params = array()) {
                $this->initialize ( $params );
        }
        
        public function initialize($params = array()) {
                if (count ( $params ) > 0) {
                        foreach ( $params as $key => $val ) {
                                if (isset ( $this->$key )) {
                                        $this->$key = $val;
                                }
                        }
                }
        }
        public function ueditor() {
                $sd = '<textarea id="' . $this->id . '" name="' . $this->id . '" style="height:300px;"> ' . $this->value . '</textarea>';
                $sd .= '<link rel="stylesheet" href="' . base_url () . 'plugins/editor/ueditor/themes/default/ueditor.css" />';
                $sd .= '<script charset="utf-8" src="' . base_url () . 'plugins/editor/ueditor/editor_config.js"></script>';
                $sd .= '<script charset="utf-8" src="' . base_url () . 'plugins/editor/ueditor/editor_all.js"></script>';
                $sd .= '<script>';
                $sd .= 'var editor;';
                $sd .= 'var editor = new baidu.editor.ui.Editor();';
                $sd .= 'editor.render(\'' . $this->id . '\');';
                $sd .= '</script>';
                return $sd;
        }
        public function kindeditor() {
                $sd = '<textarea id="' . $this->id . '" name="' . $this->id . '" style="height:300px;"> ' . $this->value . '</textarea>';
                //$sd .= '<link rel="stylesheet" href="' . base_url () . 'plugins/kindeditor/themes/default/skin.css" />';
                $sd .= '<script charset="utf-8" src="' . base_url () . 'editor/kindeditor.js"></script>';
                $sd .= '<script charset="utf-8" src="' . base_url () . 'editor/lang/zh_CN.js"></script>';
                $sd .= '<script>';
                $sd .= 'var editor;';
                $sd .= 'KindEditor.ready(function(K) {';
                $sd .= 'editor = K.create(\'#' . $this->id . '\',{\'uploadJson\' : \'' . site_url ( 'localupload/upload' ) . '?watermark=1\',\'width\':\'97%\',\'minWidth\':\'' . $this->minWidth . '\',\'minHeight\':\'300px\',\'resizeType\':\'0\',urlType : \'domain\'});';
                $sd .= '});';
                $sd .= '</script>';
                return $sd;
        }
        public function ckeditor() {
                $sd = '<textarea id="' . $this->id . '" name="' . $this->id . '" style="height:300px;"> ' . $this->value . '</textarea>';
                //$sd .= '<link rel="stylesheet" href="' . base_url () . 'plugins/kindeditor/themes/default/skin.css" />';
                $sd .= '<script charset="utf-8">window.CKEDITOR_BASEPATH="' . base_url () . 'plugins/editor/ckeditor/"</script>';
                $sd .= '<script charset="utf-8" src="' . base_url () . 'plugins/editor/ckeditor/ckeditor.js"></script>';
                $sd .= '<script>';
                $sd .= 'CKEDITOR.replace(\'' . $this->id . '\',{filebrowserImageUploadUrl:\'' . site_url ( 'swfupload/ckeditorjson' ) . '?watermark=1\'});';
                $sd .= '</script>';
                return $sd;
        }
        public function getedit($params = array(), $vs = 'ueditor') {
                if (count ( $params ) > 0) {
                        $this->initialize ( $params );
                }
                $sd = $this->$vs ();
                return $sd;
        }
 
}